﻿<%@ Page Language="C#" Trace="false" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="languages.aspx.cs" Inherits="LanguageVersioningPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

	<script>
		function deleteLanguage(languageShortName)
		{
			if (confirm("Deleting a language will delete all associated texts created in that language.\r\n\r\nReally delete " + languageShortName + "?"))
			{
				$("#delete_" + languageShortName).submit(); 
			}
		}
		function setMasterLanguage(languageShortName)
		{
			$("#setmaster_" + languageShortName).submit();
		}

		function validateLanguageForm()
		{
			valDisplayer.hideAllValidationErrors();
			var noErrors = true;

			var nameElem = $("#<% =  NameTxt.ClientID %>");
			var shortNameElem = $("#<% = ShortNameTxt.ClientID %>");
			var cultureSelElem = $("#<% = CultureSel.ClientID %>");
			if (!nameElem.val())
			{
				valDisplayer.showValidationError("Required", nameElem, "below_right");
				noErrors = false;
			}
			if (!shortNameElem.val())
			{
				valDisplayer.showValidationError("Required", shortNameElem, "below_right");
				noErrors = false;
			}
			if (cultureSelElem.val() === "-")
			{
				valDisplayer.showValidationError("Required", cultureSelElem, "below_right");
				noErrors = false;
			}

			return noErrors;
		}
		
		
	</script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">

		<h1 class="page">Languages</h1>
	
		<form id="MainForm" runat="server">
	
			<asp:PlaceHolder ID="AddHeadlinePlh" runat="server">
				<h2>Add new language</h2>
			</asp:PlaceHolder>
			<asp:PlaceHolder Visible="false" ID="EditHeadlinePlh" runat="server">
				<h2>Edit language <asp:Literal ID="EditNameLit" runat="server"></asp:Literal></h2>
			</asp:PlaceHolder>
			<div class="pageSection clearfix">
				<div class="left" style="">
					Name:<br />
					<input type="text" id="NameTxt" name="NameTxt" runat="server" style="width: 120px;" /> 
				</div>
				<div class="left" style="margin-left: 6px;">
					Short name: <br />
					<input type="text" id="ShortNameTxt" name="ShortNameTxt" runat="server" style="width: 120px;" />
				</div>
				<div class="left" style="margin-left: 6px;">
					Culture:<br />
					<select id="CultureSel" name="CultureSel" runat="server">
						<option>-</option>
						<option>af</option>
						<option>af-ZA</option>
						<option>sq</option>
						<option>sq-AL</option>
						<option>ar</option>
						<option>ar-DZ</option>
						<option>ar-BH</option>
						<option>ar-EG</option>
						<option>ar-IQ</option>
						<option>ar-JO</option>
						<option>ar-KW</option>
						<option>ar-LB</option>
						<option>ar-LY</option>
						<option>ar-MA</option>
						<option>ar-OM</option>
						<option>ar-QA</option>
						<option>ar-SA</option>
						<option>ar-SY</option>
						<option>ar-TN</option>
						<option>ar-AE</option>
						<option>ar-YE</option>
						<option>hy</option>
						<option>hy-AM</option>
						<option>az</option>
						<option>az-AZ-Cyrl</option>
						<option>az-AZ-Latn</option>
						<option>eu</option>
						<option>eu-ES</option>
						<option>be</option>
						<option>be-BY</option>
						<option>bg</option>
						<option>bg-BG</option>
						<option>ca</option>
						<option>ca-ES</option>
						<option>zh-HK</option>
						<option>zh-MO</option>
						<option>zh-CN</option>
						<option>zh-CHS</option>
						<option>zh-SG</option>
						<option>zh-TW</option>
						<option>zh-CHT</option>
						<option>hr</option>
						<option>hr-HR</option>
						<option>cs</option>
						<option>cs-CZ</option>
						<option>da</option>
						<option>da-DK</option>
						<option>div</option>
						<option>div-MV</option>
						<option>nl</option>
						<option>nl-BE</option>
						<option>nl-NL</option>
						<option>en</option>
						<option>en-AU</option>
						<option>en-BZ</option>
						<option>en-CA</option>
						<option>en-CB</option>
						<option>en-IE</option>
						<option>en-JM</option>
						<option>en-NZ</option>
						<option>en-PH</option>
						<option>en-ZA</option>
						<option>en-TT</option>
						<option>en-GB</option>
						<option>en-US</option>
						<option>en-ZW</option>
						<option>et</option>
						<option>et-EE</option>
						<option>fo</option>
						<option>fo-FO</option>
						<option>fa</option>
						<option>fa-IR</option>
						<option>fi</option>
						<option>fi-FI</option>
						<option>fr</option>
						<option>fr-BE</option>
						<option>fr-CA</option>
						<option>fr-FR</option>
						<option>fr-LU</option>
						<option>fr-MC</option>
						<option>fr-CH</option>
						<option>gl</option>
						<option>gl-ES</option>
						<option>ka</option>
						<option>ka-GE</option>
						<option>de</option>
						<option>de-AT</option>
						<option>de-DE</option>
						<option>de-LI</option>
						<option>de-LU</option>
						<option>de-CH</option>
						<option>el</option>
						<option>el-GR</option>
						<option>gu</option>
						<option>gu-IN</option>
						<option>he</option>
						<option>he-IL</option>
						<option>hi</option>
						<option>hi-IN</option>
						<option>hu</option>
						<option>hu-HU</option>
						<option>is</option>
						<option>is-IS</option>
						<option>id</option>
						<option>id-ID</option>
						<option>it</option>
						<option>it-IT</option>
						<option>it-CH</option>
						<option>ja</option>
						<option>ja-JP</option>
						<option>kn</option>
						<option>kn-IN</option>
						<option>kk</option>
						<option>kk-KZ</option>
						<option>kok</option>
						<option>kok-IN</option>
						<option>ko</option>
						<option>ko-KR</option>
						<option>ky</option>
						<option>ky-KZ</option>
						<option>lv</option>
						<option>lv-LV</option>
						<option>lt</option>
						<option>lt-LT</option>
						<option>mk</option>
						<option>mk-MK</option>
						<option>ms</option>
						<option>ms-BN</option>
						<option>ms-MY</option>
						<option>mr</option>
						<option>mr-IN</option>
						<option>mn</option>
						<option>mn-MN</option>
						<option>no</option>
						<option>nb-NO</option>
						<option>nn-NO</option>
						<option>pl</option>
						<option>pl-PL</option>
						<option>pt</option>
						<option>pt-BR</option>
						<option>pt-PT</option>
						<option>pa</option>
						<option>pa-IN</option>
						<option>ro</option>
						<option>ro-RO</option>
						<option>ru</option>
						<option>ru-RU</option>
						<option>sa</option>
						<option>sa-IN</option>
						<option>sr-SP-Cyrl</option>
						<option>sr-SP-Latn</option>
						<option>sk</option>
						<option>sk-SK</option>
						<option>sl</option>
						<option>sl-SI</option>
						<option>es</option>
						<option>es-AR</option>
						<option>es-BO</option>
						<option>es-CL</option>
						<option>es-CO</option>
						<option>es-CR</option>
						<option>es-DO</option>
						<option>es-EC</option>
						<option>es-SV</option>
						<option>es-GT</option>
						<option>es-HN</option>
						<option>es-MX</option>
						<option>es-NI</option>
						<option>es-PA</option>
						<option>es-PY</option>
						<option>es-PE</option>
						<option>es-PR</option>
						<option>es-ES</option>
						<option>es-UY</option>
						<option>es-VE</option>
						<option>sw</option>
						<option>sw-KE</option>
						<option>sv</option>
						<option>sv-FI</option>
						<option>sv-SE</option>
						<option>syr</option>
						<option>syr-SY</option>
						<option>ta</option>
						<option>ta-IN</option>
						<option>tt</option>
						<option>tt-RU</option>
						<option>te</option>
						<option>te-IN</option>
						<option>th</option>
						<option>th-TH</option>
						<option>tr</option>
						<option>tr-TR</option>
						<option>uk</option>
						<option>uk-UA</option>
						<option>ur</option>
						<option>ur-PK</option>
						<option>uz</option>
						<option>uz-UZ-Cyrl</option>
						<option>uz-UZ-Latn</option>
						<option>vi</option>
						<option>vi-VN</option>
					</select>
				</div>
				<div class="left" style="margin-left: 8px; margin-top: 14px;">
					<asp:Panel Visible="true" ID="CreateBtnPlh" runat="server">
						<asp:Button id="SaveLanguageBtn" OnClick="SaveLanguageBtnClicked" Text="Save" runat="server"></asp:Button>
					</asp:Panel>
					<asp:Panel Visible="false" ID="EditBtnPlh" runat="server">
						<asp:Button type="button" id="EditBtn" OnClick="SaveLanguageBtnClicked" Text="Save" runat="server"></asp:Button>&nbsp; <a href="languages.aspx">cancel</a>
					</asp:Panel>
				</div>
			</div>
			
		</form>
	
		<h2>Existing languages</h2>
		
		<div class="pageSection">
			<p>
				The master language determines things such as which language is shown in the datagrids, and which language the extractor tool creates the found texts in per default.
			</p>
			<p>
				<em>Master language: <% = CurrentModel.MasterLanguageShortName %></em>
			</p>
		</div>
		
		<div class="pageSection">
			<table class="grid">
			<tr>
				<th></th>
				<th>Name</th>
				<th>Short name</th>
				<th>Culture name</th>
				<th></th>
				<th></th>
				<th></th>
			</tr>
			<asp:Repeater ID="LanguageRpt" runat="server">
				<ItemTemplate>
					<tr>
						<td>
							<div class="<%# GetClassNamesForCssSprite(Convert.ToString(Eval("CultureName"))) %>">&nbsp;</div>
						</td>
						<td>
							<%# Eval("Name") %>
						</td>
						<td>
							<%# Eval("ShortName") %>
						</td>
						<td>
							<%# Eval("CultureName") %>
						</td>
						<td>
							<a href="languages.aspx?mode=edit&language=<%# Eval("ShortName") %>">edit</a>
						</td>
						<td>
							<form action="languages.aspx?mode=delete" method="post" id="delete_<%# Eval("ShortName") %>">
								<input type="hidden" name="language" value="<%# Eval("ShortName") %>" />
								<a href="javascript:void(deleteLanguage('<%# Eval("ShortName") %>'));">delete</a>
							</form>
						</td>
						<td>
							<%#
							(Convert.ToString(Eval("ShortName")) == CurrentModel.MasterLanguageShortName) ? "" : ""
							%>
							<form action="languages.aspx?mode=setmaster" method="post" id="setmaster_<%# Eval("ShortName") %>">
								<input type="hidden" name="language" value="<%# Eval("ShortName") %>" />
								<a href="javascript:void(setMasterLanguage('<%# Eval("ShortName") %>'));">set as master</a>
							</form>						

						</td>						
					</tr>			
				</ItemTemplate>
			</asp:Repeater>
			</table>
		</div>
	
</asp:Content>
